<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="../style/ucs.css">
    <link rel="stylesheet" href="../content/font/iconfont.css">
    <link rel="stylesheet" href="../style/theme.css">
</head>
<body>
<div id="giraffe"></div>
<script type="text/javascript" src="../../dist/libs/u-eventhub.js"></script>
<script type="text/javascript" src="../../dist/libs/engine.js"></script>
<script type="text/javascript" src="../../dist/ucsmy-ui.js"></script>
<script type="text/javascript">
    //个人实名信息
    var realNameInfoDM = new UDM({
        value:{
            IsNew:0, //是否有新消息
            AccType:0,
            Mobile:"",
            IsBindMobile:"",//是否绑定手机
            BindMobileUrl:"../UserInfo/index.html",//绑定手机链接
            IsBindIDCard:"",//是否验证身份
            BindIDCardUrl:"../UserInfo/index.html",//验证身份链接
            IsBindBankCard:"",//是否绑卡
            BindBankCardUrl:"../MyBankCard/index.html",//绑卡链接
            Current:"MyBankCard",  //当前选中菜单
            InvestAccountUrl:"../MyAccount11/index.html",//投资账户总览链接
            InvestListUrl:"../MyInvest/index.html",//投资记录链接
            MyBankCardUrl:"../MyBankCard/index.html",//我的银行卡链接
            InvestInfoUrl:"../UserInfo/index.html",//投资个人信息
            InvestMessageUrl:"../UserMessageCenter/index.html",//投资消息中心
            FinanceAccountUrl:"../FinanceAccount/index.html",//融资账户总览链接
            FinanceListUrl:"../FinanceList/index.html",//融资记录链接
            FinanceAccountInfoUrl:"../AccountInfo/index.html",//融资账号信息
            FinanceMessageUrl:"../CompanyMessageCenter/index.html"//融资消息中心
        }
    })
    /* 以下是添加账户弹窗中表单的数据模型 */
    var acBindingDM = new UDM({
        value:false
    })
    //开户姓名
    var acNameDM = new UDM({
        value:'赵四',
        placeholder:"请输入您的开户姓名",
        validator:[
            {type:"require",msg:"请输入您的开户姓名"}
        ]
    });
    //身份证号
    var acIdNumDM = new UDM({
        value:'2554684643146541',
        placeholder:"请输入您的身份证号码",
        validator:[
            {type:"require",msg:"请输入您的身份证号码"}
        ]
    });
    //开户行
    var acBankOptionDM = new UDM({
        value:{
            selectIndex:2,
            selectValue:'',
            selectText:'',
            options:[]
        },
        validator:[{type:'fn',fn:function () {
            if(!acBankOptionDM.value.BankId){
                return false;
            }else {
                return true;
            }
        }}],
        onChange: function (v) {
            //console.log(acBankOptionDM.getCurrentSelect());  //通过这个方法可以直接获得当前选中的值
            //执行ajax请求
            acBankOptionDM.validate();
        }
    });
//    开户省市
    var acAreaDM = new UDM({
        value:{
            provinceValue:'',
            provinceIndex:null,
            provinceText:'',
            cityValue:'',
            cityIndex:null,
            cityText:''
        },
        validator:[
            {type:"require",msg:"请输入您的身份证号码"}
        ],
        onChange:function (v) {
            acAreaDM.validate();
            acAddressOptionDM.setValue({options:[
                {
                    option: "浙商银行1111111111111111111111111111",
                    value: "316"
                },
                {
                    option: "中国工商银行",
                    value: "102"
                },
                {
                    option: "中国农业银行",
                    value: "103"
                },
                {
                    option: "中国银行",
                    value: "104"
                }
            ]})
        }
    })
    //支行
    var acAddressOptionDM = new UDM({
        value:{
            selectIndex:'',
            selectValue:'',
            selectText:'',
            options:[]
        },
        validator:[
            {type:"require",msg:"请输入您的身份证号码"}
        ],
        onChange: function (v) {
            acAddressOptionDM.validate();
            acAddressOptionDM.setValue(v);
        }
    });
    //银行账号
    var acBankNumDM = new UDM({
        value:'',
        placeholder:"仅限银行储蓄卡",
        validator:[
            {type:"require",msg:"银行账号不能为空"}
        ]
    });
    //确认银行账户
    var acBankNum2DM = new UDM({
        value:'',
        placeholder:"请再次输入银行账号",
        validator:[
            {type:"require",msg:"银行账号不能为空"},
            {
                type:"fn",
                fn:function(v){
                    if(v == acBankNumDM.getValue()){
                        return true;
                    }else{
                        return false;
                    }
                },
                msg:"两次账号输入不一致"
            }
        ]
    });
    //预留手机号码
    var acPhoneDM = new UDM({
        placeholder:"请输入预留手机号码",
        validator:[
            {type:"require",msg:"手机号码不能为空"},
            {type:"mobile"}
        ]
    });
    //图形验证码
    var acImgCodeDM = new UDM({
        placeholder:"请输入图形验证码",
        validator:[
            {type:"require",msg:"图形验证码不能为空"},
            {
                type:"fn",
                fn:function(v){
                    if(aclayerDM.clicked || acMsgBtnDM.clicked){
                        aclayerDM.clicked = false;
                        acMsgBtnDM.clicked = false;
                        console.log('22')
                        return true;
                    }else{
                        console.log('333')
//                        return CheckImageCode('LoginImgCode', v);
                    }
                },
                msg:"短信验证码错误，请重新输入"
            }
        ]
    });
    //图形验证码按钮
    var acImgBtnDM = new UDM({
        value:"../content/images/code.jpg",
        onClick:function(){
            acImgBtnDM.setValue("../content/images/logoe.jpg");
        }
    });
    //短信验证码
    var acMsgCodeDM = new UDM({
        placeholder:"请输入短信验证码",
        validator:[
            {type:"require",msg:"短信验证码不能为空"},
            {
                type:"fn",
                fn:function(v){

                },
                msg:"短信验证码错误，请重新输入"
            }
        ]
    });
    //获取验证码按钮
    var acMsgBtnDM = new UDM({
        count:3,
        clicked:false,
        onMouseDown:function () {
            acMsgBtnDM.clicked = true;
        },
        onClick:function(){
            var phoneMsg = acPhoneDM.validate(),
                imgMsg = acImgCodeDM.validate();
            if(phoneMsg && imgMsg){
                UEventHub.emit('getcode',acMsgBtnDM);
            }

//                if(!phoneMsg && !imgMsg){
//					$.ajax({
            /* code hear */
//						success:function(){
//                    var _msg = "手机号已注册";
//                    phoneDM.setError(_msg);
//						}
//					});
//					phoneDM.validate();
//					console.log(phoneDM.validate());
//                }else{
//                    return false;
//                }
        }
    });
    //复选框
    var acCheckboxDM = new UDM({
        value:true,
        onClick:function(v) {
            if (v) {
                URLDM.setValue({showTip: false})
            }
        }
    });
    /* 添加账户END */
    //链接
    var URLDM = new UDM({
        value:{
            showTip:false,
            agreement:{
                name:"新银e融平台银行卡绑定服务协议",
                link:"../BankCardServiceProtocol/index.html",
                tips:"请勾选《新银e融平台银行卡绑定服务协议》"
            }//协 议链接
        }

    });
    //添加银行卡模型
    var aclayerDM = new UDM({
        clicked:false,
        onMouseDown:function () {
            aclayerDM.clicked = true;
        },
        confirmBack:function () {
            if(acCheckboxDM.value){
                if(acBindingDM.value){
                    failMesDM.setValue('信息验证不通过')
//                    addFailDM.showDialog();
                    acPayPwdLayerDM.showDialog();
                }else {
                    acPayPwdLayerDM.showDialog();
                }
            }else {
                URLDM.setValue({showTip:true})
            }
        }
    })


    //支付密码
    var acPayPwdDM = new UDM({
        label: '支付密码：',
        placeholder:'请输入新密码',
        maxLength:6,
        validator:[
            {type:"require",msg:"密码不能为空"},
            {
                type:"fn",
                fn:function(v){
                    if(v == 123){
                        return true;
                    }else{
                        return false;
                    }
                },
                msg:"请输入正确的密码"
            }
        ]
    });
    var acPayPwd2DM = new UDM({
        label: '支付密码：',
        placeholder:'请输入新密码',
        validator:[
            {type:"require",msg:"密码不能为空"},
            {
                type:"fn",
                fn:function(v){
//						console.log(pswDM.getValue());
                    if(v == acPayPwdDM.getValue()){
                        return true;
                    }else{
                        return false;
                    }
                },
                msg:"两次输入密码不一致"
            }
        ]
    });

    var acPayPwdLayerDM = new Dialog({
        confirmBack:function () {
            console.log('设置密码成功');
            acPayPwdLayerDM.hideDialog();
            addSuccessDM.showDialog();
        },
        closeBack:function () {
            acPayPwdLayerDM.hideDialog();
        }
    })

    var addSuccessDM = new Dialog({
        confirmBack:function () {
            addSuccessDM.hideDialog();
            UDialog.alert({title:'dddd',content:'ddddd',closeBack:function () {
               window.location.href = "http://www.baidu.com";
            }})
        },
        cancelBack: function () {
            addSuccessDM.hideDialog();

        },
        closeBack: function () {
            addSuccessDM.hideDialog();

        }
    });
    var failMesDM = new UDM({
        value:''
    })
    var addFailDM = new Dialog({
        confirmBack:function () {
            addFailDM.hideDialog();
        },
        cancelBack: function () {
            addFailDM.hideDialog();

        },
        closeBack: function () {
            addFailDM.hideDialog();

        }
    })
    var ajaxFn = function () {
        /*个人实名信息*/
        var realName = {
            AccType:0,
            Mobile:"155****2132",
            IsBindMobile:true,//是否绑定手机
            BindMobileUrl:"../UserInfo/index.html",//绑定手机链接
            IsBindIDCard:false,//是否验证身份
            BindIDCardUrl:"../UserInfo/index.html",//验证身份链接
            IsBindBankCard:false,//是否绑卡
            BindBankCardUrl:"../MyBankCard/index.html",//绑卡链接
            Current:"MyBankCard",  //当前选中菜单
            InvestAccountUrl:"../MyAccount/index.html",//投资账户总览链接
            InvestListUrl:"../MyInvest/index.html",//投资记录链接
            MyBankCardUrl:"../MyBankCard/index.html",//我的银行卡链接
            InvestInfoUrl:"../UserInfo/index.html",//投资个人信息
            InvestMessageUrl:"../UserMessageCenter/index.html",//投资消息中心
            FinanceAccountUrl:"../FinanceAccount/index.html",//融资账户总览链接
            FinanceListUrl:"../FinanceList/index.html",//融资记录链接
            FinanceAccountInfoUrl:"../AccountInfo/index.html",//融资账号信息
            FinanceMessageUrl:"../CompanyMessageCenter/index.html"//融资消息中心
        };
        realNameInfoDM.setValue(realName);
        setTimeout(function () {
            acBankOptionDM.setValue({options:[
                {
                    option: "浙商银行",
                    value: "316"
                },
                {
                    option: "中国工商银行",
                    value: "102"
                },
                {
                    option: "中国农业银行",
                    value: "103"
                },
                {
                    option: "中国银行",
                    value: "104"
                }
            ]})
        },100);
        acBindingDM.setValue(true)
    }
    var PageDM = {
        realNameInfo: realNameInfoDM,
        acBinding: acBindingDM,
        acName: acNameDM,
        acIdNum: acIdNumDM,
        acArea: acAreaDM,
        acAddressOption:acAddressOptionDM,
        acBankOption: acBankOptionDM,
        acBankNum: acBankNumDM,
        acBankNum2: acBankNum2DM,
        acPhone: acPhoneDM,
        acImgCode: acImgCodeDM,
        acImgBtn: acImgBtnDM,
        acMsgCode: acMsgCodeDM,
        acMsgBtn: acMsgBtnDM,
        acCheckbox: acCheckboxDM,
        aclayer: aclayerDM,
        addSuccess: addSuccessDM,
        failMes:failMesDM,
        addFail: addFailDM,
        acPayPwd: acPayPwdDM,
        acPayPwd2:acPayPwd2DM,
        acPayPwdLayer:acPayPwdLayerDM,
        URL:URLDM
    }
    UEventHub.on('pageLoad', function(v){
        ajaxFn();
        //console.log(acBankOptionDM.getValue());
        UEventHub.emit("test","你好，","世界！");
    });
</script>
</body>
</html>